include:
  - pkg.pkg-init
Dependency_package_installation:
  pkg.installed:
    - names:
      - libnl-devel
      - libnfnetlink-devel
keepalived-install:
  file.managed:
    - name: /usr/local/src/keepalived-1.4.0.tar.gz
    - source: salt://keepalived/files/keepalived-1.4.0.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && sudo tar xf keepalived-1.4.0.tar.gz &&  cd keepalived-1.4.0 && sudo ./configure --prefix=/usr/local/keepalived && sudo make && sudo make install
    - unless: test -d /usr/local/keepalived
    - require: 
      - pkg: pkg-init
      - pkg: Dependency_package_installation
      - file: keepalived-install
keepalived-init:
  file.managed:
    - name: /etc/init.d/keepalived
    - source: salt://keepalived/files/keepalived.init
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: chkconfig --add keepalived
    - unless: chkconfig --list|grep keepalived
    - require:
      - file: keepalived-init

/etc/sysconfig/keepalived:
  file.managed:
    - source: salt://keepalived/files/keepalived.sysconfig
    - user: root
    - group: root
    - mode: 644
/etc/keepalived:
  file.directory:
    - user: root
    - group: root
    - mode: 755
 
